<?php
/**
 * [LupMisNotAllowedSync]
 * 本代码为系统自动生成代码，请根据自己业务进行修改;
 * 生成时间 2022-02-15 20:59:18;
 * 版权所有 2020-2022 lizhongwen，并保留所有权利;
 * 说明: 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用；不允许对程序代码以任何形式任何目的的再发布;
 * 作者: 中文Lee;
 * 作者主页: http://www.lizhongwen.com;
 * 邮箱: 360811363@qq.com;
 * QQ: 360811363;
 */

namespace modules\sys\controller;

use application\core\Request;
use application\core\Result;
use Exception;
use modules\sys\service\impl\AccountLoginLogServiceImpl;

class AccountLoginLogController
{

    private $service;

    public function __construct()
    {
        $this->service = new AccountLoginLogServiceImpl();
    }

    /**
     * @lupRoleCode sys:accountLoginLog:lists
     * @return array
     */
    public function lists(): array
    {
        return Result::success(false, $this->service->lists(Request::json(), Request::getPagePars()));
    }

    /**
     * @lupRoleCode sys:accountLoginLog:add
     * @return array
     */
    public function add(): array
    {
        try {
            $add = $this->service->add(Request::json());
            if ($add == 0) return Result::fail(true, [], "添加失败");
            return Result::success(true, [], "添加成功");
        } catch (Exception $e) {
            return Result::fail(true, [], $e->getMessage());
        }
    }

    /**
     * @lupRoleCode sys:accountLoginLog:edit
     * @return array
     */
    public function query(): array
    {
        return $this->service->query(Request::json());
    }

    /**
     * @lupRoleCode sys:accountLoginLog:edit
     * @return array
     */
    public function edit(): array
    {
        try {
            $edit = $this->service->edit(Request::json());
            if ($edit == 0) return Result::fail(true, [], "您未修改任何数据");
            return Result::success(true, [], "修改成功");
        } catch (Exception $e) {
            return Result::fail(true, [], $e->getMessage());
        }
    }

    /**
     * @lupRoleCode sys:accountLoginLog:del
     * @return array
     */
    public function del(): array
    {
        try {
            $delNum = $this->service->del(Request::json());
            if ($delNum == 0) return Result::fail(true, [], "您未删除任何数据");
            return Result::success(true, [], "删除成功");
        } catch (Exception $e) {
            return Result::fail(true, [], $e->getMessage());
        }
    }
}

